package com.example.helloword.demo;

import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSON;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@Slf4j
public class HellowordDemo {


    /**
     * [TestUser(id=0, mame=闫文超0, age=8),
     * TestUser(id=1, mame=闫文超1, age=16),
     * TestUser(id=2, mame=闫文超2, age=7),
     * TestUser(id=3, mame=闫文超3, age=4),
     * TestUser(id=4, mame=闫文超4, age=4),
     * TestUser(id=5, mame=闫文超5, age=23),
     * TestUser(id=6, mame=闫文超6, age=16),
     * TestUser(id=7, mame=闫文超7, age=21),
     * TestUser(id=8, mame=闫文超8, age=13),
     * TestUser(id=9, mame=闫文超9, age=13)]
     *
     * ===?[TestUser(id=0, mame=闫文超0, age=8),
     * TestUser(id=1, mame=闫文超1, age=16),
     * TestUser(id=2, mame=闫文超2, age=7),
     * TestUser(id=3, mame=闫文超3, age=4),
     * TestUser(id=4, mame=闫文超4, age=4),
     * TestUser(id=5, mame=闫文超5, age=23),
     * TestUser(id=7, mame=闫文超7, age=21),
     * TestUser(id=8, mame=闫文超8, age=13),
     * TestUser(id=9, mame=闫文超9, age=13)]
     *
     * @param args
     */
    public static void main(String[] args) {


        List<TestUser> userList = getUserList();
        log.info("userList=====>" + userList);


        List<TestUser> arrayList = new ArrayList<>();
        List<TestUser> arrayList11 = new ArrayList<>();
        for (TestUser user : userList) {
            if (user.getId() % 2 == 0) {
                if (user.getAge() > 15) {
                    arrayList11.add(user);
                    continue;
                }
            }
            arrayList.add(user);

        }
        System.out.println("===?" + arrayList.toString());
        System.out.println("===>>>>>-------" + arrayList11.toString());
    }

    private static List<TestUser> getUserList() {

        List<TestUser> list = new ArrayList<>();
        //插入用户
        for (int i = 0; i < 20; i++) {

            TestUser user = new TestUser();
            user.setId(i);
            user.setMame("闫文超" + i);
            user.setAge(getRanddomAge());
            list.add(user);

        }
        return list;
    }


    private static Integer getRanddomAge() {

        Random random = new Random();
        return random.nextInt(20);

    }


}
